package edu.sctu.wulixia.month4and5.day20150531;

import edu.sctu.zcy.month201505.subwaysystem.V1.Card;
import edu.sctu.zcy.month201505.subwaysystem.V1.PassengerInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by user05 on 2015/5/31.
 */
public class SubwayStation {
    PassengerInfo passenger = new PassengerInfo();

    public void securityCheck(int i) {

        PassengerInfo[] pass = passenger.setPassengerInfos(i);


        if (pass[i].packageOfpassenger || pass[i].waterOfpassenger) {

            System.out.println("您可能有携带危险品，请留下来配合我们检查！");
            System.out.println("---------------------\n检查完毕！");

        } else {

            System.out.println("请入站！");
        }
    }


    public void cardReader() {
        Card card = new Card();
        int money = card.getMoney();
        if (money < 2) {
            System.out.println("您的余额为" + money + "，不足2元，请充值后进站！");
        } else {
            System.out.println("祝您旅途愉快！");
        }
    }

    public List<String> way() {
        List<String> list = new ArrayList<String>();
        list.add("犀浦");
        list.add("茶店子");
        list.add("一品天下");
        list.add("蜀汉路东");
        list.add("天府广场");
        list.add("东大路");
        list.add("成渝立交");
        list.add("惠王陵");
        list.add("成都行政学院");
        list.add("书房");
        list.add("龙泉驿");
        return list;
    }

    public void deductionRules(String inceptionPoint,String terminus) {
        int i;
        int j;
        int stationNumber;
        int balance;

        Card card = new Card();

        for (i = 0; i < way().size(); i++) {
            for (j = 0; j < way().size(); j++) {

                if (inceptionPoint.contains(way().get(j)) &&
                       terminus.contains(way().get(i)))
                {

                    stationNumber = j - i;
                    int number = Math.abs(stationNumber);
                    System.out.println("坐的站数 = " + number);

                    int money = card.getMoney();
                    if (number <= 3) {
                        balance = money - 2;
                        if(balance<0){
                            System.out.println("余额不足，请充值！");
                        }else {
                            System.out.println("刷卡金额：2元\t卡里余额：" + balance);
                        }
                    } else if (number <= 6) {
                        balance = money - 4;
                        if(balance<0){
                            System.out.println("余额不足，请充值！");
                        }else {
                            System.out.println("刷卡金额：4元\t卡里余额：" + balance);
                        }
                    } else if (number <= 8) {
                        balance = money - 5;
                        if(balance<0){
                            System.out.println("余额不足，请充值！");
                        }else {
                            System.out.println("刷卡金额：5元\t卡里余额：" + balance);
                        }
                    } else {
                        balance = money - 6;
                        if(balance<0){
                            System.out.println("余额不足，请充值！");
                        }else {
                            System.out.println("刷卡金额：6元\t卡里余额：" + balance);
                        }
                    }

                }

            }
        }
    }


//    public static void main(String[] args) {
//
//        new  SubwayStation().deductionRules(2);
//    }
}

